home *** CD-ROM | disk | FTP | other *** search
/ Aminet 24 / Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso / Aminet / dev / debug / GAngelRmx1_1.lha / GuardianAngelRemix / source / macros < prev   
Text File  |  1998-02-11  |  14KB  |  766 lines

  1.     IFND    MY_MACROS_I
  2. MY_MACROS_I        SET    1
  3.  
  4.     ifnd    _LVOSupervisor
  5.     include    offsets/exec_lib.i
  6.     endc
  7.  
  8.     ifd    __M68
  9.         macfile    Macros:equs
  10.     elseif
  11.         include    Macros:equs
  12.     endc
  13.  
  14. ;    ifd    SYS
  15. ;        fail    "SYS eksisterer"
  16. ;    elseif
  17. SYS        macro
  18.         iflt    NARG-1    ;NARG=2
  19.         move.l    (\2),a6
  20.         endc
  21.         jsr    (_LVO\1,a6)
  22.         endm
  23. ;    endc
  24.  
  25.     ifnd    CALL
  26. CALL        macro
  27.         iflt    NARG-1    ;NARG=2
  28.         move.l    (\2),a6
  29.         endc
  30.         jsr    (_LVO\1,a6)
  31.         endm
  32.     endc
  33.  
  34. *------ LINKLIB for calling functions where A6 is incorrect:
  35.  
  36. SYSX    MACRO   ; functionOffset,libraryBase
  37.     IFGT    NARG-2
  38.         FAIL    "!!! LINK MACRO - too many arguments !!!"
  39.     ENDC
  40.     MOVE.L    A6,-(SP)
  41.     MOVE.L    \2,A6
  42.     JSR    _LVO\1(A6)
  43.     MOVE.L  (SP)+,A6
  44.     ENDM
  45.  
  46. MYCALL        macro
  47.         iflt    NARG-2    ;NARG=2
  48.         move.l    (\2),a6
  49.         endc
  50.         jsr    (_LVO\1,a6)
  51.         endm
  52.  
  53.     ifnd    EXEC
  54. EXEC        macro
  55.         movea.l    (EXECBase),a6
  56.         jsr    (_LVO\1,a6)
  57.         endm
  58.     endc
  59.  
  60. GRAF        macro
  61.         move.l    (GrafBase),a6
  62.         jsr    (_LVO\1,a6)
  63.         endm
  64.  
  65. DOS        macro
  66.         move.l    (DosBase),a6
  67.         jsr    (_LVO\1,a6)
  68.         endm
  69.  
  70. INT        macro
  71.         move.l    (IntBase),a6
  72.         jsr    (_LVO\1,a6)
  73.         endm
  74.  
  75. MMU        macro
  76.         move.l    MmuBase,a6
  77.         jsr    (_LVO\1,a6)
  78.         endm
  79.  
  80. ENF        macro
  81.         move.l    EnfBase,a6
  82.         jsr    (_LVO\1,a6)
  83.         endm
  84.  
  85.     IFND    EXEC_EXEC_LIB_I
  86. CALLEXEC    macro
  87.         move.l    (AbsExecBase).w,a6
  88.         jsr    (_LVO\1,a6)
  89.         endm
  90.  
  91. WaitBlit    macro
  92.         btst.b    #6,(dmaconr,cust)
  93. .busy\@        btst.b    #6,(dmaconr,cust)
  94.         bne    .busy\@
  95.         btst.b    #6,(dmaconr,cust)
  96.         endm
  97.     ENDC
  98.  
  99. GetVBR        macro
  100.         psh.l    a5/a6
  101.         movea.l    (EXECBase),a6
  102.         suba.l    a0,a0
  103.         btst.b    #AFB_68010,(AttnFlags+1,a6)
  104.         beq.b    .bull
  105.         lea    (.getvbr,pc),a5
  106.         pea    (.bull)
  107.         jmp    (_LVOSupervisor,a6)
  108. ;        jsr    (_LVOSupervisor,a6)
  109. ;        rts
  110. ;        bra    .gotvbr\@
  111. .getvbr        movec    vbr,a0
  112.         rte
  113. .bull        pll.l    a5/a6
  114.         move.l    a0,(VBRBase)
  115.         endm
  116.  
  117.     ifd    Openlib
  118.         fail
  119.     endc
  120. OpenLib        macro    ;libname,libfail,version(optional)
  121. ****** EXECBASE !MUST! exist before doing OpenLib
  122.         lea    (\1Name),a1
  123.     ifd    __M68
  124. junk    set    RARG
  125. junk2    set    NARG
  126.         ifne    RARG-3
  127.          moveq    #0,d0
  128.         elseif
  129.          move.l    #(\3),d0
  130.         endc    ;narg 3
  131.     elseif
  132.         ifeq    NARG-3        ;NARG=3
  133.          move.l    #\3,d0
  134.         elseif
  135.          moveq    #0,d0
  136.         endc    ;narg 3
  137.     endc
  138.         EXEC    OpenLibrary
  139.         move.l    d0,(\1Base)
  140.         beq    \2
  141.         endm
  142.  
  143. CloseLib    macro
  144. ****** EXECBASE !MUST! exist before doing CloseLib
  145.         move.l    (\1Base),d0
  146.         beq.b    .base_empty\@
  147.         movea.l    d0,a1
  148.         EXEC    CloseLibrary
  149.         clr.l    (\1Base)
  150. .base_empty\@
  151.         endm
  152.  
  153. LongToString    macro
  154. ; \1 = data register
  155. ; \2 dscratch
  156. ; \3 areg output
  157.         ifne    NARG-3
  158.             fail    LongToString_wrong_arg_count
  159.         endc
  160.         moveq    #7,\2
  161. .nybble\@    swap    \2
  162.         rol.l    #4,\1
  163.         move.b    \1,\2
  164.         and.w    #$0f,\2
  165.         move.b    (Nybble2Ascii,pc,\2.w),(\3)+
  166.         swap    \2
  167.         dbra    \2,.nybble\@
  168.         endm
  169.  
  170. NYBBLE2ASCII    macro
  171.         dc.b    "0123456789ABCDEF"
  172.         endm
  173.  
  174. Byte2Ascii    macro    *!* a1 = conversion buffer
  175.             *!* d1 = byte
  176.             *!* d2 = scratch
  177.             *!* stack = result
  178.         moveq    #0,d2        ; clear d2
  179.         move.b    d1,d2        ; copy the byte
  180.         lsr.b    #4,d2        ; get upper nybble
  181.         move.b    (a1,d2.l),d2    ; store in reg
  182.         lsl.w    #8,d2        ; "swap" bytes
  183.         and.w    #$000f,d1    ; get lower nybble
  184.         move.b    (a1,d1.w),d2    ; store in reg
  185.         move.w    d2,-(sp)    ; psh result word on stack
  186.         endm            ; that's it
  187.  
  188. PrintByte    macro    *!* d0 = byte
  189.             *!* needs an error-label \1
  190.         psh.l    d1-d3/a0-a1/a6    ; don't crash what we don't use
  191.         lea    (Nybble2Ascii),a1
  192.         move.b    d0,d1        ; pass over the byte
  193.         Byte2Ascii
  194.         move.l    (StdOut),d1    ; use standard output
  195.         move.l    sp,d2        ; where is that friggin' byte
  196.         moveq    #2,d3        ; and there is only 1 byte = 2 ascii
  197.         DOS    Write        ; do your business
  198.         add.l    d3,sp        ; reset the sp
  199.         pll.l    d1-d3/a0-a1/a6
  200.         tst.l    d0        ; how is business today?
  201.         beq    \1        ; it goes to hell
  202.         endm            ; that's all!
  203.  
  204. PrintWord    macro    *!* d0 = word
  205.             *!* needs an error-label \1
  206.         psh.l    d1-d3/a0-a1/a6    ; don't crash what we doesn't use
  207.         lea    (Nybble2Ascii),a1
  208.         move.b    d0,d1        ; get lower byte
  209.         Byte2Ascii
  210. ;        moveq    #0,d1
  211.         move.w    d0,d1        ;copy that word
  212.         lsr.w    #8,d1        ;get upper byte
  213.         Byte2Ascii
  214.         move.l    (StdOut),d1    ; use standard output
  215.         move.l    sp,d2        ; where is that friggin' word
  216.         moveq    #4,d3        ; and there are only 2 bytes = 4 ascii
  217.         DOS    Write        ; do your business
  218.         add.l    d3,sp        ; reset the sp
  219.         pll.l    d1-d3/a0-a1/a6
  220.         tst.l    d0        ; how is business today?
  221.         beq    \1        ; it goes to hell
  222.         endm            ; that's all!
  223.  
  224. PrintLong    macro    *!* d0 = long
  225.             *!* needs an error-label \1
  226.         psh.l    d1-d3/a0-a1/a6    ; don't crash what we doesn't use
  227.         lea    (Nybble2Ascii),a1
  228. ;        moveq    #0,d1
  229.         move.b    d0,d1        ; get lower byte
  230.         Byte2Ascii
  231.         move.w    d0,d1        ; move it over
  232.         lsr.w    #8,d1        ; get byte 2
  233.         Byte2Ascii
  234.         swap    d0        ; get upper word
  235.         move.b    d0,d1        ; get byte 3
  236.         Byte2Ascii
  237.         move.w    d0,d1        ; move it
  238.         lsr.w    #8,d1        ; get upper byte
  239.         Byte2Ascii
  240.         move.l    (StdOut),d1    ; use standard output
  241.         move.l    sp,d2        ; where is that friggin' long
  242.         moveq    #8,d3        ; and there are only 4 bytes = 8 ascii
  243.         DOS    Write        ; do your business
  244.         add.l    d3,sp
  245.         pll.l    d1-d3/a0-a1/a6
  246.         tst.l    d0        ; how is business today?
  247.         beq    \1        ; it goes to hell
  248.         endm            ; that's all!
  249.  
  250. PrintStr    macro    *!* a0 = adr
  251.             *!* needs an error-label \1
  252.         psh.l    d0-d3/a1/a6    ; don't crash what we doesn't use
  253.         move.l    (StdOut),d1    ; use standard output
  254.         move.l    a0,d2        ; buffer
  255. .findEOS\@    tst.b    (a0)+
  256.         bne    .findEOS\@
  257.         sub.l    d2,a0
  258.         subq.l    #1,a0
  259.         move.l    a0,d3
  260.         DOS    Write        ; do your business
  261.         tst.l    d0        ; how is business today?
  262.         pll.l    d0-d3/a1/a6
  263.         beq    \1        ; it goes to hell
  264.         endm            ; that's all!
  265.  
  266.  
  267. PrintSPC    macro    *!* d0 = number of spaces
  268.         ifeq    NARG-2        ;NARG=2
  269.         moveq    #\2,d0
  270.         endc
  271.         psh.l    d1-d3/a0-a2/a6    ; don't crash what we doesn't use
  272.         move.l    sp,a2        ; remember the stack
  273.         cmp.l    #255,d0        ; check if there are too many
  274.         bgt    .to_many_spaces\@
  275.         move.l    d0,d3        ; this is how long the string is
  276.         lsr.w    #1,d0
  277. .putspaceonstack\@
  278.         move.w    #"  ",-(sp)    ; use the stack to build the string
  279.         dbra    d0,.putspaceonstack\@
  280.         move.l    (StdOut),d1    ; use standard output
  281.         move.l    sp,d2        ; get that adress
  282.         DOS    Write        ; let's see it
  283.         move.l    a2,sp        ; restore the stack
  284. .to_many_spaces\@
  285.         pll.l    d1-d3/a0-a2/a6
  286.         tst.l    d0
  287.         beq    \1
  288.         endm
  289.  
  290.  
  291. PrintEOL    macro
  292.         psh.l    d0-d3/a0-a1/a6
  293.         move.l    (StdOut),d1
  294.         move.w    #$0a00,-(sp)    ; stuff a word with LF on the stack
  295.         move.l    sp,d2        ; we know where it is now
  296.         moveq    #1,d3        ; just the return
  297.         DOS    Write        ; get it done
  298.         addq.l    #2,sp        ; fix the sp
  299.         tst.l    d0        ; check for errors
  300.         pll.l    d0-d3/a0-a1/a6    ; restore our status
  301.         beq    \1        ; if there was an error...
  302.         endm
  303.  
  304.  
  305. MyWaitBlit    macro
  306.         btst.b    #6,(dmaconr,cust)
  307. ;.mybusy\@    btst.b    #6,(dmaconr,cust)
  308. ;        beq    .mybusy1\@
  309. ;        move.w    a0,(col00,cust)
  310. .mybusy2\@    btst.b    #6,(dmaconr,cust)
  311.         bne    .mybusy2\@
  312. .mybusy1\@    btst.b    #6,(dmaconr,cust)
  313.         endm
  314.  
  315. ABSMyWaitBlit    macro
  316.         btst.b    #6,(DMACONR)
  317. .mybusy2\@    btst.b    #6,(DMACONR)
  318.         bne    .mybusy2\@
  319. .mybusy1\@    btst.b    #6,(DMACONR)
  320.         endm
  321.  
  322. *debugged
  323. BNasty        macro
  324.         move.w    #%1000010000000000,(dmacon,cust)    ;blitternasty
  325.         endm
  326. ABSBNasty    macro
  327.         move.w    #%1000010000000000,(DMACON)    ;blitternasty
  328.         endm
  329. *debugged
  330. BNice        macro
  331.         move.w    #%0000010000000000,(dmacon,cust)    ;blitternice
  332.         endm
  333. ABSBNice    macro
  334.         move.w    #%0000010000000000,(DMACON)    ;blitternice
  335.         endm
  336. *debugged
  337. HoldAndGo    macro
  338. ;        BNasty
  339. ;        MyWaitBlit
  340.         OSWaitBlit
  341. ;        jsr    $fc59ec    ;jsr (a5) where a5=-228(GFXBASE)
  342. ;        BNice
  343.         endm
  344. *debugged
  345. ABSHoldAndGo    macro
  346.         ABSBNasty
  347.         ABSMyWaitBlit
  348.         ABSBNice
  349.         endm
  350.  
  351. OSWaitBlit    macro
  352.         psh.l    d0/d1/a0/a1/a6
  353.         GRAF    WaitBlit
  354.         pll.l    d0/d1/a0/a1/a6
  355.         endm
  356.  
  357. ABSSYSHoldAndGo    macro
  358.         ABSBNasty
  359.         SYS    WaitBlit
  360.         ABSBNice
  361.         endm
  362.  
  363. ABSCALLHoldAndGo    macro
  364.         ABSBNasty
  365.         move.l    a6,-(sp)
  366.         GRAF    WaitBlit
  367.         move.l    (sp)+,a6
  368.         ABSBNice
  369.         endm
  370.  
  371. AbsStopCopper    macro
  372.         move.w    #%0000000010000000,(DMACON)
  373.         endm
  374.  
  375. StopCopper    macro
  376.         move.w    #%0000000010000000,(dmacon,cust)
  377.         endm
  378. *debugged
  379. AbsCopperStrobe    macro
  380.         move.w    d0,(COPJMP1)        ; anything will strobe
  381.         endm
  382.  
  383. CopperStrobe    macro
  384.         move.w    d0,(copjmp1,cust)    ; anything will strobe
  385.         endm
  386.  
  387. StartCopper    macro
  388.         move.w    #%1000000010000000,(dmacon,cust)
  389.         CopperStrobe
  390.         endm
  391.  
  392. AbsStartCopper    macro
  393.         move.w    #%1000000010000000,(DMACON)
  394.         AbsCopperStrobe
  395.         endm
  396.  
  397. AbsUseCopperlist    macro    *!* needs 1 parameter
  398.         AbsStopCopper
  399.         move.l    #\1,(COP1LC)
  400.         AbsStartCopper
  401.         endm
  402.  
  403. UseCopperlist    macro    *!* needs 1 parameter
  404.         StopCopper
  405.         move.l    #\1,(cop1lc,cust)
  406.         StartCopper
  407.         endm
  408.  
  409. WaitFirebutton    macro
  410. .press\@    btst.b    #7,CIAApra
  411.         bne.b    .press\@
  412.         endm
  413.  
  414. LMB        macro
  415. .getleft\@    btst.b    #6,$bfe001
  416.         bne    .getleft\@
  417.         endm
  418.  
  419. LMB_ud        macro
  420. .getleftd\@    btst.b    #6,$bfe001
  421.         bne    .getleftd\@
  422. .get